/**
  ******************************************************************************
  * @file    img processing2.h
  * @author  Amaseing team
  * @version V1.0.0
  * @date    21-november-2013
  * @brief   Img processing2
  *         
  ******************************************************************************  
  */ 
#ifndef _IMG_PROCESSING2_H_
#define _IMG_PROCESSING2_H_

/* Public includes -----------------------------------------------------------*/
#include "cam.h"
#include "operators.h"

/* Public defines ------------------------------------------------------------*/
//Capture ROI settings
#define IMP2_CAPTURE_WIDTH		(160)
#define IMP2_CAPTURE_HEIGHT		(160) 

#define IMP2_WIDTH_MAX			(144) 
#define IMP2_WIDTH_OFFSET		(16)
 
#define IMP2_HEIGHT_MAX			(144) 
#define IMP2_HEIGHT_OFFSET		(16) 

#define IMP2_FIND_YSTR_DEV		(15)
#define IMP2_FIND_YSTR_SUB 		(10)

//Object minimal surface
#define IMP2_OBJ_SURFACE_MIN	(250)

//Object Q1 settings
#define IMP2_OBJ_SQUARE_Q1_MIN		(0.15f)
#define IMP2_OBJ_SQUARE_Q1_MAX		(0.190f)

#define IMP2_OBJ_TRIANGLE_Q1_MIN	(0.190f)
#define IMP2_OBJ_TRIANGLE_Q1_MAX	(0.24f)

#define IMP2_OBJ_BAR_Q1_MIN			(0.24f)
#define IMP2_OBJ_BAR_Q1_MAX			(0.35f)

//Object Q2 settings
#define IMP2_OBJ_SQUARE_Q2_MAX		(0.01f)

//Error checking
#if IMP2_CAPTURE_WIDTH*IMP2_CAPTURE_HEIGHT > IMG_WIDTH*IMG_HEIGHT
	#error "Not enough IMG_MEMORY for a capture with IMP2_CAPTURE_WIDTH and IMP2_CAPTURE_HEIGHT"
#endif
#if IMP2_WIDTH_MAX+IMP2_WIDTH_OFFSET > IMP2_CAPTURE_WIDTH
	#error "(IMP2_WIDTH_MAX + IMP2_WIDTH_OFFSET) don't fit in IMP2_CAPTURE_WIDTH"
#endif
#if IMP2_HEIGHT_MAX+IMP2_HEIGHT_OFFSET > IMP2_CAPTURE_HEIGHT
	#error "(IMP2_HEIGHT_MAX + IMP2_HEIGHT_OFFSET) don't fit in IMP2_CAPTURE_HEIGHT"
#endif

//Objects
enum eOBJECTS{
	OBJ_UNKNOWN = 0,
	OBJ_SQUARE,
	OBJ_TRIANGLE,
	OBJ_BAR,
	OBJ_SIZE //the size of the enum eOBJECTS
};

/* Public functions ----------------------------------------------------------*/
// Init
void imgP2Init(void);

// img process 2: Color detection & Object Recognition
// Passes an image for processing. After calling this, the contents of img are modified.
void imgP2(image_t* img);

#endif /*_IMG_PROCESSING2_H_*/

